﻿<phone:PhoneApplicationPage 
    x:Class="MobiSms.Wasun.Views.SerialDetailsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:viewmodel="clr-namespace:MobiSms.ViewModel;assembly=MobiSms.ViewModel"
    xmlns:UX="clr-namespace:MobiSms.UX;assembly=MobiSms.UX"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="message_itemstyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Button Margin="0,0,0,12"
                                Click="GotoDetailsView"
                                Tag="{Binding Guid}">
                            <Button.Style>
                                <Style TargetType="Button">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="Button">
                                                <StackPanel>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Path Width="24"
                                                              Height="24"
                                                              Margin="12"
                                                              Data="M-150.204,626.126C-152.317,626.126 -154.429,626.126 -156.541,626.126 -167.642,633.42 -180.629,646.047 -189.668,657.238 -190.916,658.782 -192.945,662.362 -193.701,662.422 -194.041,662.448 -198.024,659.719 -198.614,659.297 -202.818,656.279 -205.779,653.709 -209.257,650.899 -211.248,652.172 -212.879,653.805 -214.153,655.797 -206.627,665.074 -200.283,675.534 -193.124,685.18 -181.491,665.11 -168.473,644.683 -152.796,629.006 -151.735,627.946 -149.817,626.933 -150.204,626.126z"
                                                              Fill="{StaticResource PhoneForegroundBrush}"
                                                              RenderTransformOrigin="0.5,0.5"
                                                              Stretch="Uniform"
                                                              Visibility="{Binding Status,
                                                                                   ConverterParameter=Succeed,
                                                                                   Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <TransformGroup.Children>
                                                                        <RotateTransform Angle="0" />
                                                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                    </TransformGroup.Children>
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path Width="24"
                                                              Height="24"
                                                              Margin="12"
                                                              Data="M29.9314,44.295944L34.223,44.295944 34.223,48.586002 29.9314,48.586002z M29.749001,26.198L34.390999,26.198 34.390999,31.451971 33.290699,42.814522 30.8636,42.814522 29.749001,31.451971z M32,10.338882L8.2226601,54.42371 55.777302,54.42371z M32,0L48,29.665951 64,59.331001 32,59.331001 0,59.331001 16,29.665951z"
                                                              Fill="{StaticResource PhoneForegroundBrush}"
                                                              RenderTransformOrigin="0.5,0.5"
                                                              Stretch="Uniform"
                                                              Visibility="{Binding Status,
                                                                                   ConverterParameter=Faild,
                                                                                   Converter={StaticResource ValueEqualsParameterToVisibilityConverter}}">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <TransformGroup.Children>
                                                                        <RotateTransform Angle="0" />
                                                                        <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                    </TransformGroup.Children>
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" 
                                                                   Text="{Binding SendId, Converter={StaticResource MessageSendIdConverter}}" />
                                                    </StackPanel>
                                                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}"
                                                               Text="{Binding DisplayContent}"
                                                               TextWrapping="Wrap" />
                                                </StackPanel>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Button.Style>
                        </Button>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:SerialDetailsViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush ImageSource="{Binding GlobalSettings.BackgroundImage}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}" />
        </Grid.Background>
        <controls:Pivot Title="{StaticResource IDS_APP_NAME}">
            <controls:PivotItem Header="{StaticResource IDS_SERIAL_DETAILS_HEADER}">
                <Grid>
                    <ScrollViewer>
                        <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_SERIAL}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.SerialNumber}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text=" "/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_PASSWORD}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.Password}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text=" "/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_SERVICECODE}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.ServiceCode}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text=" "/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_SIGNATURE}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.Signature}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text=" "/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_SENTCOUNT}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.SentCount}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text=" "/>
                            <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_BALANCE}"/>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding SelectedSerial.Balance}"/>
                        </StackPanel>
                    </ScrollViewer>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="{StaticResource IDS_SERIAL_DETAILS_MESSAGE_HEADER}">
                <Grid>
                    <ListBox ItemContainerStyle="{StaticResource message_itemstyle}" ItemsSource="{Binding ItemsOfMessage}" />
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="{StaticResource IDS_SERIAL_DETAILS_UPDATE_HEADER}">
                <Grid Margin="0,0,12,0">
                    <StackPanel>
                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_SIGNATURE}"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBox Text="{Binding NewSign, Mode=TwoWay, UpdateSourceTrigger=Explicit}" TextChanged="OnTextBoxTextChanged"/>
                            <UX:UXPathButton Grid.Column="1" IconPath="{StaticResource PATH_ICON_SUBMIT}" Command="{Binding UpdateSignatureCommand}"/>
                        </Grid>
                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{StaticResource IDS_SERIAL_PASSWORD}"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBox Text="{Binding NewPassword, Mode=TwoWay, UpdateSourceTrigger=Explicit}" TextChanged="OnTextBoxTextChanged" InputScope="Number" />
                            <UX:UXPathButton Grid.Column="1" IconPath="{StaticResource PATH_ICON_SUBMIT}" Command="{Binding UpdatePasswordCommand}" />
                        </Grid>
                        <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text=" "/>
                        <UX:UXIconTextButton Path="{StaticResource PATH_ICON_DELETE}" Content="{StaticResource IDS_SERIAL_DETAILS_DELETE}" Margin="12" Command="{Binding Path=DeleteCommand}" />
                    </StackPanel>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

</phone:PhoneApplicationPage>